import { Injectable } from "@nestjs/common";
import { EventEmitter2 } from "@nestjs/event-emitter";

@Injectable()
export class GlobalStatusService {
  static isLaserOpen = false;
  static diskUsage = {
    localC: {
      used: 0,
      total: 0,
      usePercent: 0,
    },
    localD: {
      used: 0,
      total: 0,
      usePercent: 0,
    },
  };

  constructor(private readonly eventEmitter: EventEmitter2) {}

  updateDiskUsage(diskUsage: any) {
    Object.assign(GlobalStatusService.diskUsage, diskUsage);
  }

  toggleLaser = () => {
    GlobalStatusService.isLaserOpen = !GlobalStatusService.isLaserOpen;
    this.eventEmitter.emit("global.status.change");
  };
}
